package PracticasPL.Practica3;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StringReader;

import antlr.ANTLRException;

/**
 * Hello world!
 *
 */
public class Procesador 
{
    public static void main( String[] args )
    {
    	try { 
    		if(args.length > 0)
    		{
    			FileInputStream fis = 
    					new FileInputStream(args[0]); 
    			Analex analex = null; 
    			Anasint anasint = null; 
    			analex = new Analex(fis); 
    			anasint = new Anasint(analex); 
    			anasint.entrada();
    			
    		}else
    		{
    			InputStreamReader isr = 
    					new InputStreamReader(System.in); 
    			BufferedReader br = new BufferedReader(isr); 
    			String linea = br.readLine(); 
    			while (!linea.equals("$")) { 
    				Analex analex = null; 
    				Anasint anasint = null; 
    				analex = new Analex(new StringReader(linea)); 
    				anasint = new Anasint(analex); 
    				anasint.entrada_tec(); 
    				linea = br.readLine();
    				}
    			
    		}
    		}catch(ANTLRException ae) { 
    			System.err.println(ae.getMessage()); 
    		} 
    		catch(FileNotFoundException fnfe) { 
    			System.err.println("No se encontró el fichero"); 
    		} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
    	System.out.print("Procesador terminado");
    }
  }

